public class SolutionInterview10_10 {

    int[] h=new int[50005];

    public SolutionInterview10_10() {

    }

    public void track(int x) {
        x++;
        while (x<=50001){
            h[x]++;
            x+=lowbit(x);
        }
    }

    public int getRankOfNumber(int x) {
        x++;
        int t=0;
        while (x>0){
            t+=h[x];
            x-=lowbit(x);
        }
        return t;
    }

    int lowbit(int x){
        return x&(-x);
    }

    public static void main(String[] args) {
        SolutionInterview10_10 solutionInterview10_10=new SolutionInterview10_10();
        System.out.println(solutionInterview10_10.getRankOfNumber(1));
        solutionInterview10_10.track(0);
        System.out.println(solutionInterview10_10.getRankOfNumber(0));
    }
}
